using System;

using NLog;

namespace Outcoding.GraphGenerator.Util.Logging {
    public class LogManager {

        #region Class Members

        #region Private Members

        private static LogManager mInstance;

        private Logger mLogger;

        #endregion

        #region Properties

        /// <summary>
        /// Singleton access instance.
        /// </summary>
        public static LogManager Instance {
            get {
                if (mInstance == null)
                    mInstance = new LogManager();
                return mInstance;
            }
        }

        #endregion

        #endregion

        #region Constructors (1)
        /// <summary>
        /// Private default constructor. Creates a new instance of Outcoding.GraphGenerator.Util.Logging.LogManager for internal use only.
        /// </summary>
        private LogManager() {
            try {
                mLogger = NLog.LogManager.GetCurrentClassLogger();
            } catch (Exception exc) {
                throw exc;
            }
        }

        #endregion

        #region Public Methods (12)

        #region LogTrace
        /// <summary>
        /// Write a trace message to the target.
        /// </summary>
        /// <param name="message">The message to log.</param>
        public void LogTrace(string message) {
            mLogger.Trace(message);
        }
        #endregion

        #region LogTrace and Exception
        /// <summary>
        /// Write a trace message and an exception to the target.
        /// </summary>
        /// <param name="message">The message to log.</param>
        /// <param name="exception">The Exception to append to the log message.</param>
        public void LogTrace(string message, Exception exception) {
            mLogger.Trace(message);
            mLogger.Trace(exception.Data);
            mLogger.Trace(exception.InnerException);
            mLogger.Trace(exception.Message);
            mLogger.Trace(exception.Source);
            mLogger.Trace(exception.StackTrace);
        } 
        #endregion

        #region LogDebug
        /// <summary>
        /// Write a debug message to the target.
        /// </summary>
        /// <param name="message">The message to log.</param>
        public void LogDebug(string message) {
            mLogger.Debug(message);
        } 
        #endregion

        #region LogDebug and Exception
        /// <summary>
        /// Write a debug message and an exception to the target.
        /// </summary>
        /// <param name="message">The message to log.</param>
        /// <param name="exception">The Exception to append to the log message.</param>
        public void LogDebug(string message, Exception exception) {
            mLogger.Debug(message);
            mLogger.Debug(exception.Data);
            mLogger.Debug(exception.InnerException);
            mLogger.Debug(exception.Message);
            mLogger.Debug(exception.Source);
            mLogger.Debug(exception.StackTrace);
        } 
        #endregion

        #region LogInfo
        /// <summary>
        /// Write an info message to the target.
        /// </summary>
        /// <param name="message">The message to log.</param>
        public void LogInfo(string message) {
            mLogger.Info(message);
        } 
        #endregion

        #region LogInfo and Exception
        /// <summary>
        /// Write an info message and an exception to the target.
        /// </summary>
        /// <param name="message">The message to log.</param>
        /// <param name="exception">The Exception to append to the log message.</param>
        public void LogInfo(string message, Exception exception) {
            mLogger.Info(message);
            mLogger.Info(exception.Data);
            mLogger.Info(exception.InnerException);
            mLogger.Info(exception.Message);
            mLogger.Info(exception.Source);
            mLogger.Info(exception.StackTrace);
        } 
        #endregion

        #region LogWarning
        /// <summary>
        /// Write a warning message to the target.
        /// </summary>
        /// <param name="message">The message to log.</param>
        public void LogWarning(string message) {
            mLogger.Warn(message);
        } 
        #endregion

        #region LogWarning and Exception
        /// <summary>
        /// Write a warning message and an exception to the target.
        /// </summary>
        /// <param name="message">The message to log.</param>
        /// <param name="exception">The Exception to append to the log message.</param>
        public void LogWarning(string message, Exception exception) {
            mLogger.Warn(message);
            mLogger.Warn(exception.Data);
            mLogger.Warn(exception.InnerException);
            mLogger.Warn(exception.Message);
            mLogger.Warn(exception.Source);
            mLogger.Warn(exception.StackTrace);
        } 
        #endregion

        #region LogError
        /// <summary>
        /// Write an error message to the target.
        /// </summary>
        /// <param name="message">The message to log.</param>
        public void LogError(string message) {
            mLogger.Error(message);
        } 
        #endregion

        #region LogError and Exception
        /// <summary>
        /// Write an error message and an exception to the target.
        /// </summary>
        /// <param name="message">The message to log.</param>
        /// <param name="exception">The Exception to append to the log message.</param>
        public void LogError(string message, Exception exception) {
            mLogger.Error(message);
            mLogger.Error(exception.Data);
            mLogger.Error(exception.InnerException);
            mLogger.Error(exception.Message);
            mLogger.Error(exception.Source);
            mLogger.Error(exception.StackTrace);
        } 
        #endregion

        #region LogFatal
        /// <summary>
        /// Write a fatal error message to the target.
        /// </summary>
        /// <param name="message">The message to log.</param>
        public void LogFatal(string message) {
            mLogger.Fatal(message);
        } 
        #endregion

        #region LogFatal and Exception
        /// <summary>
        /// Write a fatal error message and an exception to the target.
        /// </summary>
        /// <param name="message">The message to log.</param>
        /// <param name="exception">The Exception to append to the log message.</param>
        public void LogFatal(string message, Exception exception) {
            mLogger.Fatal(message, exception);
            mLogger.Fatal(exception.Data);
            mLogger.Fatal(exception.InnerException);
            mLogger.Fatal(exception.Message);
            mLogger.Fatal(exception.Source);
            mLogger.Fatal(exception.StackTrace);
        } 
        #endregion

        #endregion
    }
}
